<template>
	<view class="container">
		<view v-for="(item,index) in infoList" :key="index"  class="container_item">
			<view class="avatar">
				<image :src="item.carType.img"></image>
			</view>
			<view class="container_item_text">
				<view>
					<text>车型：</text>
					<text>{{item.carBrand.bname}}{{item.carType.name}}</text>
				</view>
				<view>
					<text>车牌：</text>
					<text>{{item.carNum}}</text>
				</view>
				<!-- 设为默认 -->
				<view>
					<text>设为默认</text>
				</view>
			</view>
		</view>
		<!-- 添加车辆 -->
		<view class="btn" @click="add">
			<button>添加爱车</button>
		</view>
		<!-- <view class="img" v-if="1==1">
			<image src="/static/v2_rq2c07.png" mode=""></image>
			<text>暂无车辆信息</text>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				infoList:[]
			}
		},
		created() {
			this.getMyCar(); // 在组件创建时获取卡片数据
			this.getEva();
		},
		methods: {
			add(){
				uni.navigateTo({
					url:'/pages/my/myVehicle/addVehicle'
				})
			},
			getMyCar(){
				uni.request({
					url: 'http://localhost:9207/info/list',
					method: 'GET', // 请求方法
					data: {}, // 请求体，传递的数据
					header:{
						 // 'Authorization': `Bearer ${token}`
						//  'Authorization': `Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjA2NzkxYWFiLWFlYmMtNDQ2Yy1iOTNjLTM0YWJiNWExZDAxNSIsInVzZXJuYW1lIjoiYWRtaW4ifQ.rOzX8DtBXl9l3LIfvsFhvEieOAPi-ptVQNfiudg8oiKkv1rdZpV0wjOhIooHqVIq85yRvaXmVmksuSqiL0Ldfg`,
						// 'Cookie': 'Admin-Token=eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjA2NzkxYWFiLWFlYmMtNDQ2Yy1iOTNjLTM0YWJiNWExZDAxNSIsInVzZXJuYW1lIjoiYWRtaW4ifQ.rOzX8DtBXl9l3LIfvsFhvEieOAPi-ptVQNfiudg8oiKkv1rdZpV0wjOhIooHqVIq85yRvaXmVmksuSqiL0Ldfg; Admin-Expires-In=720; sidebarStatus=0'
					},
					success: (res) => {
						console.log('请求成功:', res.data.rows);
						this.infoList = res.data.rows;
					},
					fail: (err) => {
						console.error('请求失败:', err);
					}
				});
			},
			getEva() {
				uni.request({
					url: 'http://localhost:9206/evaluate/list',
					method: 'GET', // 请求方法
					data: {}, // 请求体，传递的数据
					header: {
						// 'Authorization': `Bearer ${token}`
						// Authorization: `Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjA2NzkxYWFiLWFlYmMtNDQ2Yy1iOTNjLTM0YWJiNWExZDAxNSIsInVzZXJuYW1lIjoiYWRtaW4ifQ.rOzX8DtBXl9l3LIfvsFhvEieOAPi-ptVQNfiudg8oiKkv1rdZpV0wjOhIooHqVIq85yRvaXmVmksuSqiL0Ldfg`,
						// Cookie: 'Admin-Token=eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjA2NzkxYWFiLWFlYmMtNDQ2Yy1iOTNjLTM0YWJiNWExZDAxNSIsInVzZXJuYW1lIjoiYWRtaW4ifQ.rOzX8DtBXl9l3LIfvsFhvEieOAPi-ptVQNfiudg8oiKkv1rdZpV0wjOhIooHqVIq85yRvaXmVmksuSqiL0Ldfg; Admin-Expires-In=720; sidebarStatus=0'
					},
					success: (res) => {
						console.log('请求成功:', res);
						this.evaList = res.data.data;
					},
					fail: (err) => {
						console.error('请求失败:111', err);
					}
				});
			},
		}
	}
</script>

<style>
	.container{
		background-color: #FFFFFF;
	}
	.container_item{
		display: flex;
	}
	.avatar{
		display: flex;	
	}
	.avatar image{
		width: 77px;
		height: 77px;
		border-radius: 45px;
		margin: 18px 0 18px 17px;
	}
	.container_item_text {
		padding: 18px 27px;
	}
	.container_item_text view:nth-child(2){
		margin: 7.5px 0;
	}
	.container_item_text text {
		height: 20px;
		line-height: 20px;
		font-size: 14px;
	}
	.btn{
		/* 绝对定位 */
		/* position: fixed; */
		/* left: 41px;
		bottom: 30px; */
		margin: 30px auto;
		font-family: Roboto;
	}
	.btn button{
		width: 282px;
		height: 39px;
		line-height: 39px;
		font-size: 14px;
		text-align: center;
		background-color: #1D6FFF;
		color: #FFFFFF;
		border-radius: 25px;
	}
	
	/* 没有车辆显示图片 */
	.img > image{
		/* 绝对定位 */
		position: absolute;
		left: 135px;
		top: 198px;
		width: 100px;
		height: 100px;
	}
	
	.img > text {
		/* 绝对定位 */
		position: absolute;
		left: 140px;
		top: 310px;
		font-size: 14px;
		color: #999999;
	}
</style>
